package smallChanges.Tokenization;
import java.util.HashMap;
import java.util.Iterator;

public class TokenMultiset extends HashMap<Long,Long> {
	
	
	public TokenMultiset difference(TokenMultiset other)
	{
		TokenMultiset retVal = new TokenMultiset();
		Iterator<Long> thisIter = keySet().iterator();
		Long left, right;
		Long key;
		
		while(thisIter.hasNext())
		{
			left = 0L;
			right = 0L;
			
			key = thisIter.next();
			
			left = get(key);
			
			right = other.get(key);
			if( right == null )
			{
				right = 0L;
			}
			retVal.put(key, left - right);
		}
		
		left = 0L;
		thisIter = other.keySet().iterator();
		while(thisIter.hasNext())
		{
			right = 0L;
			
			key = thisIter.next();
			
			right =  (Long)other.get(key);
			
			if( get(key) == null )
			{
				retVal.put(key, left - right);
			}
		}
		
		return retVal;
	}
}
